<?php session_start();$_SESSION['page'] = 'admin';?>
<?php
    $adminID = $_GET['adminID'];

    require('db_connection.php');
    $query = "SELECT * FROM tbladmin WHERE adminID='$adminID'";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result))
    {
        $userName = $row['userName'];
        $userType = $row['userType'];
        $libraryNo1 = $row['libraryNo'];
        $firstName = $row['firstName'];
        $middleName = $row['middleName'];
        $lastName = $row['lastName'];
        $password = $row['password'];
        $address = $row['address'];
        $contactNo = $row['contactNo'];
        $email = $row['email'];
        $adminID = $row['adminID'];
    }
?>

<!doctype html public "-//W3C//DTD HTML 4.01//EN">
<html>

   <head>
      <title>Administrator Edit</title>
      <meta http-equiv="generator" content="PHP Designer 2005" />
      <style type="text/css">
        @import url(style.css);
      </style>
   </head>

   <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000" class=''>

    <?php echo "<form method='post' action='update.php?page=admin&adminID=$adminID'>"; ?>
    <table width='80%' align='center' class='content'>
        <tr><td colspan='2'><img src='images/banner.jpg'></td></tr>
        <tr><td align='right' colspan='2' class='logout'><?php require ('loginout.php');?></td></tr>
        <tr class='menuborder'><td width='90%'><img src='images/adminedit.png'></td><td><?php  require('buttons2.php'); ?></td></tr>
        <tr><td colspan='2' class='bodyborder'>
            <table width='60%' align='center'>
                <?php
                echo "<tr><td height='30' colspan='2'></td></tr>";
                echo "<tr><td>User Name</td>";
                echo "<td><input type='text' name='userName' value='$userName' size='45'/></td></tr>";
                echo "<tr><td>Library Name</td>";
                echo "<td><select name='libraryNo'>";
                
                $qlib = "SELECT * FROM tbllibrary";
                $rlib = mysql_query($qlib);
                while ($row = mysql_fetch_array($rlib))
                {
                    $libraryNo = $row['libraryNo'];
                    $libraryName = $row['libraryName'];
                  
                    if($libraryNo==$libraryNo1)
                    {
                        echo "<option value='$libraryNo' selected='selected'>$libraryName</option>";
                    }
                    else
                    {
                        echo "<option value='$libraryNo'>$libraryName</option>";
                    }
                }

                echo "</select></td></tr>";
                echo "<tr><td>First Name</td>";
                echo "<td><input type='text' name='firstName' value='$firstName' size='45'/></td></tr>";
                echo "<tr><td>Middle Name</td>";
                echo "<td><input type='text' name='middleName' value='$middleName'size='45'/></td></tr>";
                echo "<tr><td>Last Name</td>";
                echo "<td><input type='text' name='lastName' value='$lastName'size='45'/></td></tr>";
                echo "<tr><td>Password</td>";
                echo "<td class='pass'><a href='cpass.php?adminID=$adminID'><font size='2'>[ Change Password ]</font></a></td></tr>";
                echo "<tr><td>Address</td>";
                echo "<td><input type='text' name='address' value='$address' size='45'/></td></tr>";
                echo "<tr><td>Contact No</td>";
                echo "<td><input type='text' name='contactNo' value='$contactNo' size='45'/></td></tr>";
                echo "<tr><td>E-mail Address</td>";
                echo "<td><input type='text' name='email' value='$email' size='45'/></td></tr>";
                echo "<tr><td>User Type</td>";
                echo "<td><select name='userType'>";

                if($userType=='superadministrator')
                {
                    echo "<option value='$userType' selected='selected'>Super Administrator</option>";
                    echo "<option value='administrator'>Administrator</option>";
                    echo "<option value='staff'>Staff</option>";
                }
                if($userType=='administrator')
                {
                    echo "<option value='superadministrator'>Super Administrator</option>";
                    echo "<option value='$userType' selected='selected'>Administrator</option>";
                    echo "<option value='staff'>Staff</option>";
                }
                if($userType=='staff')
                {
                    echo "<option value='superadministrator'>Super Administrator</option>";
                    echo "<option value='administrator'>Administrator</option>";
                    echo "<option value='$userType' selected='selected'>Staff</option>";
                }
                echo "</select></td></tr>";
                echo "<tr><td colspan='3' align='right'><input type='submit' value='Update' class='tool'></td></tr>";
                
                ?>
            </table>
            </td>
        </tr>
        <tr><td align='center' colspan='2'><?php require ('copyright.php')?></td></tr>
    </table>
    </form>

   </body>
</html>

